<template>
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" size="small">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
		<div class="bt">班级信息</div>


				<el-form label-width="100px" class="form">
					<div class="an" style="width: 100%;text-align: center;float: left;">
					<el-button type="info" class="submit" style="float: left;margin-right: 5px;" @click="submit">修改</el-button>
					<el-button type="info" class="submit" style="float: left;margin-right: 5px" @click="kaiban">正式开班</el-button>
					<el-button type="info" class="submit" style="float: left;margin-right: 5px" @click="jiesan">解散班级</el-button>

			</div>
					<div class="left" style="float: left;width: 50%; margin-top: 10px;">
					<el-form-item label="名称">
						<el-input v-model="form.mc" placeholder="请输入" class="select-block"></el-input>
					</el-form-item>
					<!-- <el-form-item label="行政老师">
					<el-select v-model="form.xzlsmc" placeholder="请选择行政老师" class="select-block">
						<el-option :label="v.xslsmc" :value="v.xzlsid+''" v-for="v in xzlsList"></el-option>
					</el-select>
			</el-form-item> -->
					<el-form-item label="老师名称">
						<el-select v-model="form.lsmc" class="select-block">
							<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="开班日期">
						<el-date-picker v-model="form.kbsjd" type="date" class="select-block" placeholder="选择日期" @keyup.enter.native="search"> </el-date-picker>
					</el-form-item>

					</div>

					<div class="right" style="float: left;width: 50%;margin-top: 10px;">
					<el-form-item label="教材">
						<el-input v-model="form.jcmc" placeholder="请选择教材名称" class="select-block1" icon="add" :readonly="true"></el-input>
						<!--<el-input v-model="form.jcid"  :v-if="false"  placeholder="请选择教材名称" class="select-block1" icon="add" :readonly="true"></el-input>
						<el-input v-model="form.cid"  :v-if="false"  placeholder="请选择教材名称" class="select-block1" icon="add" :readonly="true"></el-input>-->
						<el-button size="small" @click="showjc()" class="select-block2">选择</el-button>
					</el-form-item>
					<el-form-item label="分校课程">
						<el-input v-model="form.fxkcmc" placeholder="请选择分校课程" class="select-block1" icon="add" :readonly="true"></el-input>
						<!--<el-input v-model="form.fxkcid" :v-if="false" placeholder="请选择分校课程" class="select-block1" icon="add" :readonly="true"></el-input>-->
						<el-button size="small"  @click="showwp()" class="select-block2">选择</el-button>
					</el-form-item>
					<el-form-item label="新班时段">
						<el-input v-model="form.yjkbrq" placeholder="请输入" class="select-block"></el-input>
					</el-form-item>
					</div>
					<!--<div style="float: left;width: 100%;">
						<el-form-item label="新班时段" >-->
						<!--<div  class="select-block" style="border: 1px solid #CCCCCC;">
							<el-select class="zjselect-block" >
  					               <el-option label="周一" value="周一"></el-option>
  					               <el-option label="周二" value="周二" ></el-option>
  					               <el-option label="周三" value="周三" ></el-option>
  					               <el-option label="周四" value="周四" ></el-option>
  					               <el-option label="周五" value="周五" ></el-option>
  					               <el-option label="周六" value="周六" ></el-option>
  					               <el-option label="周日" value="周日" ></el-option>
  			                </el-select>
  			                <el-time-picker  :picker-options="{selectableRange: '' }" placeholder="任意时间点"> </el-time-picker>
						</div>-->
						<!--<el-date-picker
						      v-model="value2"
						      type="datetime"
						      placeholder="选择日期时间"
						      align="right"
						      :picker-options="pickerOptions1">
						</el-date-picker>
					</el-form-item>
 			        </div>-->


					<div style="float: left;width: 100%;">
					<el-form-item label="备注">
 				        <el-input v-model="form.note" type="textarea" :rows="4" placeholder="请输入备注信息" class="select-block"></el-input>
 			        </el-form-item>
 			        </div>

					<!-- <el-form-item label="是否启用">
			<el-select v-model="form.isqy"   class="select-block" >
  					  <el-option label="启用" value="Y"></el-option>
  					<el-option label="禁用" value="N" ></el-option>
  			</el-select>
  			</el-form-item> -->
					<!-- <el-form-item label="分校课程ID">
 				<el-input v-model="form.fxkcid"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item> -->

					<PayArticle class="wpfl1" @jcarticle="jcarticleed" @close="jcarticlecancel" v-if="showarticle"></PayArticle>
					<Kschoose class="wpfl" @wpchoose="wpchooseed" @close="wpchoosecancel" v-if="showchoselist"></Kschoose>
				</el-form>
                 <div class="xsmc" style="float: left; padding: 5px 0 15px 0; width: 100%;">学生信息</div>
				<el-table :data="xsdataList" stripe style="width: 100%">
					<el-table-column prop="zwm" label="中文名"></el-table-column>
					<el-table-column prop="ywm" label="英文名"> </el-table-column>
					<el-table-column prop="xb" label="性别"></el-table-column>
					<el-table-column prop="dh" label="电话"></el-table-column>
					<el-table-column prop="csrq" label="出生日期"></el-table-column>
				</el-table>

			<!--<el-collapse-item title="班级课表" name="3">
				<el-table :data="kbdataList" style="width: 100%">
					<el-table-column prop="bjmc" label="班级名称"> </el-table-column>
					<el-table-column prop="jsmc" label="教室名称"> </el-table-column>
					<el-table-column prop="lsmc" label="老师名称"> </el-table-column>
					<el-table-column prop="sj" label="排课时间"> </el-table-column>
					<el-table-column prop="issk" label="上否上课"> </el-table-column>
				</el-table>
			</el-collapse-item>-->
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	import Kschoose from '../../manage/kssz/kschoose'
	import PayArticle from './pay-articlejc'
	export default {
		props: ['params'],
		components: { Kschoose, PayArticle },
		data() {
			return {
				zwm: '',
				ywm: '',
				xb: '',
				dh: '',
				csrq: '',
				activeName: '1',
				form: {
					mc: '',
					lsmc: '',
					lsid: '',
					cmc: '',
					jcmc: '',
					isqy: '',
					fxkcid: '',
					id: '',
					xzls: '',
					yjkbrq: '',
					kbsjd:'',
					note:'',
				},
				xzlsList: [],
				comboxlist: [],
				xsdataList: [],
//				kbdataList: [],
				showchoselist: false,
				showarticle: false,


				 pickerOptions1: {
			          shortcuts: [{
			            text: '今天',
			            onClick(picker) {
			              picker.$emit('pick', new Date());
			            }
			          }, {
			            text: '昨天',
			            onClick(picker) {
			              const date = new Date();
			              date.setTime(date.getTime() - 3600 * 1000 * 24);
			              picker.$emit('pick', date);
			            }
			          }, {
			            text: '一周前',
			            onClick(picker) {
			              const date = new Date();
			              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
			              picker.$emit('pick', date);
			            }
			          }]

			        },

			          value2: '',
			}
		},
		created() {
//			this.form.id = this.params.row.id;
			console.log(this.params)
			if(this.params.id){
				this.form.id = this.params.id;
			}else{
				this.form.id = this.params.row.id;
			}
			this.getcomboxlist();
			this.loadinfo();
			this.xs();
//			this.kb();
		},
		methods: {

				everefbjlit() {
						Hub.$emit('change','hehe'); //Hub触发事件
			},
//			kb() {
//				var logininfo = JSON.parse(localStorage.logininfo);
//				this.axios.get(this.$store.state.api + 'pk/bjkb', {
//						params: {
//							bjid: this.params.row.id,
//							yhid: logininfo.id,
//							xxid: logininfo.xxid
//						}
//					})
//					.then(res => {
//						console.log(res)
//						let data = res.data.data;
//						let list = data.list;
//						this.xsdataList = list;
//					}).catch(res => {
//						console.log(res)
//					})
//			},
			xs() {

				var logininfo = JSON.parse(localStorage.logininfo);

				  this.axios.get(this.$store.state.api + 'xs/getysbjxss', {
					params: {
						zwm: this.zwm,
						ysbjid: this.form.id+'',
						yhid: logininfo.id + '',
						xxid: logininfo.xxid + '',
						pageindex: 1,
						pagesize: 1000,
					}
				}).then(res => {
					console.log(res)
					let data = res.data.data;
						let list = data.list;
						this.xsdataList = list;
					this.searchLoading = false;
				}).catch(res => {
					console.log(res)
					this.searchLoading = false;
				})

			},
			showwp() {
				this.showchoselist = true;
			},
			showjc() {
				this.showarticle = true;
			},
			wpchooseed(josndata) {
				this.form.fxkcmc = josndata.kcmc;
				this.form.fxkcid = josndata.fxkcid;

				this.showchoselist = false;
			},
			jcarticleed(josndata) {
				this.form.cid = josndata.cid;
				this.form.jcid = josndata.jcid;
				this.form.jcmc = josndata.jcidmc;
				this.showarticle = false;
			},
			wpchoosecancel() {
				this.showchoselist = false;
			},
			jcarticlecancel() {
				this.showarticle = false;
			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				this.axios.get(this.$store.state.api + 'ls/getlslist', {
					params: {
						yhid: logininfo.id,
						xxid: logininfo.xxid
					}
				}).then(res => {
					console.log(res)
					let data = res.data.data;
					let list = data.list;
					this.comboxlist = list;
					console.log(this.comboxlist)
				}).catch(res => {
					console.log(res)
					this.searchLoading = false;
				})
			},
			loadinfo() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.axios.get(this.$store.state.api + 'ysbj/info', {
					params: {
						xxid: logininfo.xxid,
						yhid: logininfo.id,
						id: this.form.id
					}
				}).then(res => {
					this.form = res.data.data
				}).catch(res => {
					this.$emit('close', { type: 'info', cancel: true });
				})
			},
			kaiban() {
				// alert(this.form.id)
				this.axios.get(this.$store.state.api + 'ysbj/kb',{
						params:{
								id:this.form.id
						},
				}).then( res => {
						console.log(res)
						this.cancel()
				}).catch( res => {
						console.log(res)
						this.searchLoading = false;
				})
			},
			jiesan() {
				var logininfo = JSON.parse(localStorage.logininfo);
				// alert(this.form.id)
				this.axios.get(this.$store.state.api + 'ysbj/jsbj',{
						params:{
							yhid: logininfo.id,
						    xxid:logininfo.xxid,
							ysbjid:this.form.id
						},
				}).then( res => {
						console.log(res)
						this.cancel()
				}).catch( res => {
						console.log(res)
						this.searchLoading = false;
				})
			},
			submit() {
				//检测
//				this.$store.state.loading = true;
				/*if(!this.form.id) {
					this.$message.warning('请填写分类');
					this.$store.state.loading = false;
					return;
				}*/
				//装载数据
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.form.kbsjd));
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					id: this.form.id,
					mc: this.form.mc,
					lsid: this.form.lsid,
					fxkcid: this.form.fxkcid,
					jcid: this.form.jcid,
					cid: this.form.cid,
					yjkbrq: this.form.yjkbrq,
					kbsjd: time1,
				    note:this.form.note,
					yhid: logininfo.id,
					xxid: logininfo.xxid
				})
				// this.everefbjlit();
				//执行
				this.axios.post(this.$store.state.api + 'ysbj/update', params2)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'edit', cancel: false });
//							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'edit', cancel: false });
						}
					}).catch(res => {
						alert("服务器异常");
					})
			},
			cancel() {
				this.$emit('close', { type: 'edit', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.row {
			height: 50px;
			line-height: 50px;
		}
		.bt {
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color: white;
			text-align: left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close {
			z-index: 10;
			position: absolute;
		}
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width: 280px;
			display: inline-block;
			margin-left: 10px;
		}
		.input1 {
			width: 210px;
			display: inline-block;
			margin-left: 10px;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
		}
		.wpfl {
			background: #fff;
			position: absolute;
			top: 5px;
			left: 5px;
		}
		.wpfl1 {
			width: 100%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
		}
		.form {
			text-align: left;
			margin-top: 10px;
			.select-block {
				width: 85%;
				display: block;
			}
			.select-block1 {
				width: 68%;
				// display: block;
			}
			.zjselect-block {
				width: 20%;
				float: left;
				display: block;
			}
			.el-form-item{
				margin-bottom: 10px;
			}
		}
	}
</style>
